#pragma once

#include "EngineEntityCollection.h"
#include "IEngineComponentCollection.h"
#include "EngineEntity.h" 
#include "ISystemConfiguration.h"
#include "SystemCollection.h"
#include "SettingsManager.h"
#include "EnginePointer.h"
#include "EngineObject.h"
#include "Message.h"
#include "MessageQueue.h"

using namespace std;

class Engine : public EngineObject
{
public:
	Engine(EnginePointer<ISystemConfiguration>& sysConfig, EnginePointer<SettingsManager>& settings);
	~Engine();

	HRESULT Initialize();
	void Run();
	void DeliverMessage(Message m);
	HRESULT AddEntity(EnginePointer<EngineEntity>& entity);

	AUTO_SIZE;
private:
	BOOL initialized;
	BOOL running;
	EnginePointer<EngineEntityCollection> entities;
	EnginePointer<IEngineComponentCollection> components;
	EnginePointer<SystemCollection> systems;
	EnginePointer<SettingsManager> settings;
	EnginePointer<MessageQueue> messages;

	HRESULT InitializeSystems();
};
